<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .test {
            border: 1px solid red;
        }

        h1 {
            /* width: 25.5px; */
            color: rgb(84, 84, 119);
        }

        canvas {
            margin-top: 40px;
            /* border: 4px solid rebeccapurple; */
        }

        .icon {
            width: 60px;
            height: 50px;
            background: url('./imgs/cat.jpg') no-repeat;
            background-size: 100% 100%;
        }

        .icon2 {
            width: 60px;
            height: 50px;
            background: url('./imgs/BBGS.jpg') no-repeat;
            background-size: 100% 100%;
        }

        .list {
            padding: 10px 20px;
        }

        .item {
            display: flex;
            margin-bottom: 10px;
            box-shadow: 0px 2px 20px #999;
            border-radius: 10px;
        }

        .icon {
            border-radius: 10px;
        }

        .rt {
            padding-left: 10px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .test {
            position: relative;
            /* height: 400px; */
        }

        .p3 {
            position: relative;
            top: 14px;
            width: 100px;
            height: 100px;
            background-color: aqua;
            border-radius: 10px;
        }

        .p4 {
            position: relative;
            top: -54px;
            z-index: -1;
            width: 100px;
            height: 100px;
            background-color: rgb(212, 73, 73);
        }

        .p9 {
            position: absolute;
            width: 100px;
            height: 100px;
            left: 60px;
            top: 20px;
            z-index: -10;
            background-color: rebeccapurple;
        }
        .p5{
            position: absolute;
            width: 100px;
            height: 100px;
            top: 200px; 
            z-index: 1;
            background-color: burlywood;
        }
        .p6{
            position: absolute;
            width: 100px;
            height: 100px;
            top: 270px; 
            z-index: 9;
            background-color: rgb(120, 170, 92);
        }
        .p10{
            margin-top: 100px;
            width: 100px;
            height: 100px;
            background-color: rgb(36, 77, 138);
        }
        .p11{
            margin-top: -10px;
            width: 100px;
            height: 100px;
            background-color: rgb(190, 42, 66);

        }
    </style>
</head>

<body>
    <h1>canvas绘制测试 定位层级测试</h1>
    <div class="test">
        <div class="p1">
            <div class="p3">p3</div>
            <div class="p4">p4</div>
        </div>
        <div class="p2">
            <div class="p5">p5</div>
            <div class="p6">
                <div class="p7">p7</div>
                <div class="p8">p8</div>
            </div>
        </div>
        <div class="p9">p9</div>
        <div class="p10">p10</div>
        <div class="p11">p11</div>
    </div>
    <h1>canvas绘制</h1>
    <canvas id="canvas"></canvas>
</body>
<script src="../dist/main.js"></script>

<script>
    const root = document.querySelector('.test')
    layout(root, 'canvas')
    let timer;
    window.addEventListener('resize', () => {
        if (timer) { clearTimeout(timer) }
        timer = setTimeout(function () {
            layout(root, 'canvas')

        }, 100);
    })
</script>
<script>
    let arr = [
        [0],
        [0, 0],
        [0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, -1],
        [0, 0, -1, 0],
        [0, 0],
        [0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0, 0],
        [0, 10],
        [0, 10, 0],
    ]
</script>

</html>